using BardsTaleMapViewer;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace BardsTaleMapViewer {
  public class Cell {
    public DungeonLevel _dungeonLevel;
    public int _x;
    public int _y;

    //public int _cellInfo1;
    //public int _cellInfo2;

    private static Pen _gridColor = new Pen (Color.FromArgb (224, 224, 224));
    private static Brush _cellColor = new SolidBrush (Color.FromArgb (255, 255, 255));
    private static Brush _wallColor = new SolidBrush (Color.FromArgb (0, 0, 0));
    private static Brush _doorColor = new SolidBrush (Color.FromArgb (255, 255, 255));
    private static Brush _doorOutlineColor = new SolidBrush (Color.FromArgb (0, 0, 0));
    private static Brush _hiddenDoorColor = new SolidBrush (Color.FromArgb (255, 128, 255));
    private static Brush _hiddenDoorOutlineColor = new SolidBrush (Color.FromArgb (0, 0, 0));
    private static Brush _specialColor = new SolidBrush (Color.FromArgb (0, 255, 0));
    private static Pen _trapColor = new Pen (Color.FromArgb (255, 192, 0));
    private static Brush _monsterColor = new SolidBrush (Color.FromArgb (255, 0, 0));
    //private static HatchBrush _darknessColor = new HatchBrush (HatchStyle.Percent50, Color.FromArgb (0, 0, 0), Color.FromArgb (0, 0, 0, 0));
    private static Brush _darknessColor = new SolidBrush (Color.FromArgb (64, 0, 0, 0));
    private static Brush _drainColor = new SolidBrush (Color.FromArgb (255, 192, 0));
    private static Brush _regenerateColor = new SolidBrush (Color.FromArgb (0, 192, 255));
    private static Pen _teleportColor = new Pen (Color.FromArgb (92, 0, 0, 255));
    private static Pen _teleportOutlineColor = new Pen (Color.FromArgb (0, 0, 0, 255));
    public static int _wallThickness = 2;
    public static int _doorThickness = 2;
    public static int _hiddenDoorThickness = 2;

    public enum Direction {
      North = 0,
      South = 1,
      East = 2,
      West = 3
    }

    public Cell (DungeonLevel dungeonLevel, int x, int y) {
      _dungeonLevel = dungeonLevel;
      _x = x;
      _y = y;

      //_cellInfo1 = cellInfo1;
      //_cellInfo2 = cellInfo2;

      int nb = 0;
      if (HasRandomMonster)
        nb++;
      if (HasStairsUp)
        nb++;
      if (HasStairsDown)
        nb++;
      if (HasHoleUp)
        nb++;
      if (HasHoleDown)
        nb++;
      if (nb > 1)
        throw new Exception ();
    }

    public int CellInfo1 {
      get {
        return (_dungeonLevel._cellsInfo1 [_x, _y]);
      }
    }

    public int CellInfo2 {
      get {
        return (_dungeonLevel._cellsInfo2 [_x, _y]);
      }
    }

    public bool WallBit (Direction direction) {
      return ((CellInfo1 & (1 << (((int) direction) * 2 + 0))) != 0);
    }

    public bool DoorBit (Direction direction) {
      return ((CellInfo1 & (1 << (((int) direction) * 2 + 1))) != 0);
    }

    public bool IsWall (Direction direction) {
      return (WallBit (direction) && !DoorBit (direction));
    }

    public bool IsNormalDoor (Direction direction) {
      return (!WallBit (direction) && DoorBit (direction));
    }

    public bool IsHiddenDoor (Direction direction) {
      return (WallBit (direction) && DoorBit (direction));
    }

    public bool IsEmpty (Direction direction) {
      return (!WallBit (direction) && !DoorBit (direction));
    }

    public bool HasStairsUp {
      get {
        return (((CellInfo2 >> 0) & 0x01) == 1);
      }
    }

    public bool HasStairsDown {
      get {
        return (((CellInfo2 >> 1) & 0x01) == 1);
      }
    }

    public bool HasSpecial {
      get {
        return (((CellInfo2 >> 2) & 0x01) == 1);
      }
    }

    public bool HasDarkness {
      get {
        return (((CellInfo2 >> 3) & 0x01) == 1);
      }
    }

    public bool HasTrap {
      get {
        return (((CellInfo2 >> 4) & 0x01) == 1);
      }
    }

    public bool HasHoleDown {
      get {
        return (((CellInfo2 >> 5) & 0x01) == 1);
      }
    }

    public bool HasHoleUp {
      get {
        return (((CellInfo2 >> 6) & 0x01) == 1);
      }
    }

    public bool HasRandomMonster {
      get {
        return (((CellInfo2 >> 7) & 0x01) == 1);
      }
    }

    public List<int> GetSpecialsEventIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsEventYX));
    }

    public List<int> GetSpecialsAntiMagicIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsAntiMagicYX));
    }

    public List<int> GetSpecialsTeleportIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsTeleportYX));
    }

    public List<int> GetSpecialsSpinnerIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsSpinnerYX));
    }

    public List<int> GetSpecialsSmokeIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsSmokeYX));
    }

    public List<int> GetSpecialsDrainHealthPointIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsDrainHealthPointYX));
    }

    public List<int> GetSpecialsRegenerateSpellPointIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsRegenerateSpellPointYX));
    }

    public List<int> GetSpecialsImmobilizeIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsImmobilizeYX));
    }

    public List<int> GetSpecialsTextIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsTextYX));
    }

    public List<int> GetSpecialsFightIndex () {
      return (GetSpecialsIndex (_dungeonLevel._specialsFightYX));
    }

    private List<int> GetSpecialsIndex (List<Point> specials) {
      List<int> specialsIndex = new List<int> ();
      for (int i = 0; i < specials.Count; i++) {
        Point coordXY = specials [i];
        if ((coordXY.X == _x) && (coordXY.Y == _y))
          specialsIndex.Add (i);
      }
      return (specialsIndex);
    }

    public void DrawLayer1 (Graphics g, int x, int y, int size) {
      // Floor
      DrawFloor (g, x, y, size, HasSpecial, false);

      // Special Drain Health Point
      List<int> specialsDrainHealthPointIndex = GetSpecialsDrainHealthPointIndex ();
      if (specialsDrainHealthPointIndex.Count > 0)
        DrawSpecialDrainHealthPoint (specialsDrainHealthPointIndex, g, x, y, size);

      // Special Regenerate Spell Pöint
      List<int> specialsRegenerateSpellPointIndex = GetSpecialsRegenerateSpellPointIndex ();
      if (specialsRegenerateSpellPointIndex.Count > 0)
        DrawSpecialRegenerateSpellPoint (specialsRegenerateSpellPointIndex, g, x, y, size);

      // Trap
      if (HasTrap) {
        DrawTrap (g, x, y, size);
      }

      // Darkness
      if (HasDarkness)
        DrawDarkness (g, x, y, size);

      // Wall
      if (!IsEmpty (Cell.Direction.North))
        DrawWall (g, x, y, size, Cell.Direction.North);
      if (!IsEmpty (Cell.Direction.East))
        DrawWall (g, x, y, size, Cell.Direction.East);
      if (!IsEmpty (Cell.Direction.South))
        DrawWall (g, x, y, size, Cell.Direction.South);
      if (!IsEmpty (Cell.Direction.West))
        DrawWall (g, x, y, size, Cell.Direction.West);

      // Door
      if (IsNormalDoor (Cell.Direction.North))
        DrawDoorNormal (g, x, y, size, Cell.Direction.North);
      if (IsNormalDoor (Cell.Direction.East))
        DrawDoorNormal (g, x, y, size, Cell.Direction.East);
      if (IsNormalDoor (Cell.Direction.South))
        DrawDoorNormal (g, x, y, size, Cell.Direction.South);
      if (IsNormalDoor (Cell.Direction.West))
        DrawDoorNormal (g, x, y, size, Cell.Direction.West);

      // Hidden Door
      if (IsHiddenDoor (Cell.Direction.North))
        DrawDoorHidden (g, x, y, size, Cell.Direction.North);
      if (IsHiddenDoor (Cell.Direction.East))
        DrawDoorHidden (g, x, y, size, Cell.Direction.East);
      if (IsHiddenDoor (Cell.Direction.South))
        DrawDoorHidden (g, x, y, size, Cell.Direction.South);
      if (IsHiddenDoor (Cell.Direction.West))
        DrawDoorHidden (g, x, y, size, Cell.Direction.West);
    }

    public static void DrawFloor (Graphics g, int x, int y, int size, bool hasSpecial, bool noGrid) {
      if (hasSpecial)
        g.FillRectangle (_specialColor, x, y, size, size);
      //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, "S", Color., AlignementH.Center, AlignementV.Center, true);
      else
        g.FillRectangle (_cellColor, x, y, size, size);
      // Grid
      if (noGrid)
        g.DrawRectangle (Pens.Black, x, y, size - 1, size - 1);
      else
        g.DrawRectangle (_gridColor, x, y, size - 1, size - 1);
    }

    public void DrawLayer2 (Graphics g, int x, int y, int size) {
      List<int> specialsTeleportIndex = GetSpecialsTeleportIndex ();
      if (specialsTeleportIndex.Count > 0)
        DrawSpecialTeleport (specialsTeleportIndex, g, x, y, size);
    }

    public void DrawLayer3 (Graphics g, int x, int y, int size) {
      // Stairs
      if (HasStairsUp)
        DrawStairsUp (g, x, y, size);
      //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 1 }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
      if (HasStairsDown)
        DrawStairsDown (g, x, y, size);
      //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 2 }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);

      // Monster
      if (HasRandomMonster)
        DrawRandomMonster (g, x, y, size);
      //g.FillEllipse (_monsterColor, x + _doorThickness + 6, y + _doorThickness + 6, size - (_doorThickness + 6) * 2 - 1, size - (_doorThickness + 6) * 2 - 1);
      //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 5 }), Color.Red, AlignementH.Center, AlignementV.Center, false);

      if (HasHoleUp) {
        DrawHoleUp (g, x, y, size);
        //g.FillRectangle (Brushes.Red, x + size / 2 - 2, y + size / 2 - 3, 4, 6);
        //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 1 }), Color.Black, AlignementH.Center, AlignementV.Center, false);
        //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 1 }), Color.Red, AlignementH.Center, AlignementV.Center, Color.White);
        //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, "2", Color.Red, AlignementH.Center, AlignementV.Center, true);
      }

      if (HasHoleDown) {
        DrawHoleDown (g, x, y, size);
        //g.FillRectangle (Brushes.Red, x + size / 2 - 2, y + size / 2 - 3, 4, 6);
        //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 2 }), Color.Black, AlignementH.Center, AlignementV.Center, false);
        //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 2 }), Color.Red, AlignementH.Center, AlignementV.Center, Color.White);
        //Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, "1", Color.Red, AlignementH.Center, AlignementV.Center, true);
      }

      List<int> specialsEventIndex = GetSpecialsEventIndex ();
      if (specialsEventIndex.Count > 0)
        DrawSpecialEvent (specialsEventIndex, g, x, y, size);

      List<int> specialsAntiMagicIndex = GetSpecialsAntiMagicIndex ();
      if (specialsAntiMagicIndex.Count > 0)
        DrawSpecialAntiMagic (specialsAntiMagicIndex, g, x, y, size);

      List<int> specialsSpinnerIndex = GetSpecialsSpinnerIndex ();
      if (specialsSpinnerIndex.Count > 0)
        DrawSpecialSpinner (specialsSpinnerIndex, g, x, y, size);

      List<int> specialsSmokeIndex = GetSpecialsSmokeIndex ();
      if (specialsSmokeIndex.Count > 0)
        DrawSpecialSmoke (specialsSmokeIndex, g, x, y, size);

      List<int> specialsImmobilizeIndex = GetSpecialsImmobilizeIndex ();
      if (specialsImmobilizeIndex.Count > 0)
        DrawSpecialImmobilize (specialsImmobilizeIndex, g, x, y, size);

      List<int> specialsTextIndex = GetSpecialsTextIndex ();
      if (specialsTextIndex.Count > 0)
        DrawSpecialText (specialsTextIndex, g, x, y, size);

      List<int> specialsFightIndex = GetSpecialsFightIndex ();
      if (specialsFightIndex.Count > 0)
        DrawSpecialFight (specialsFightIndex, g, x, y, size);
    }

    public static void DrawWall (Graphics g, int x, int y, int size, Direction direction) {
      if (direction == Cell.Direction.North)
        g.FillRectangle (_wallColor, x, y, size, _wallThickness);
      else if (direction == Cell.Direction.East)
        g.FillRectangle (_wallColor, x + size - _wallThickness, y, _wallThickness, size);
      else if (direction == Cell.Direction.South)
        g.FillRectangle (_wallColor, x, y + size - _wallThickness, size, _wallThickness);
      else if (direction == Cell.Direction.West)
        g.FillRectangle (_wallColor, x, y, _wallThickness, size);
    }

    public static void DrawDoorNormal (Graphics g, int x, int y, int size, Direction direction) {
      DrawDoor (g, x, y, size, _doorColor, _doorOutlineColor, _doorThickness, direction);
    }

    public static void DrawDoorHidden (Graphics g, int x, int y, int size, Direction direction) {
      DrawDoor (g, x, y, size, _hiddenDoorColor, _hiddenDoorOutlineColor, _hiddenDoorThickness, direction);
    }

    public static void DrawDoor (Graphics g, int x, int y, int size, Brush color, Brush outlineColor, int thickness, Direction direction) {
      float a = 0.25f;
      float c = 0.5f;
      if (direction == Cell.Direction.North) {
        g.FillRectangle (outlineColor, x + size * a - 1, y, size * c + 2, thickness + 1);
        g.FillRectangle (color, x + size * a, y, size * c, thickness);
      }
      if (direction == Cell.Direction.East) {
        g.FillRectangle (outlineColor, x + size - thickness - 1, y + size * a - 1, thickness + 1, size * c + 2);
        g.FillRectangle (color, x + size - thickness, y + size * a, thickness, size * c);
      }
      if (direction == Cell.Direction.South) {
        g.FillRectangle (outlineColor, x + size * a - 1, y + size - thickness - 1, size * c + 2, thickness + 1);
        g.FillRectangle (color, x + size * a, y + size - thickness, size * c, thickness);
      }
      if (direction == Cell.Direction.West) {
        g.FillRectangle (outlineColor, x, y + size * a - 1, thickness + 1, size * c + 2);
        g.FillRectangle (color, x, y + size * a, thickness, size * c);
      }
    }

    private void DrawSpecialEvent (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      //int eventIndex = _dungeonLevel._specialsEventIndex [specialsIndex [0]];
      DrawSpecialEvent_ (g, x, y, size, specialsIndex [0].ToString ());
    }

    public static void DrawSpecialEvent_ (Graphics g, int x, int y, int size, string index) {
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, string.Format ("E{0}", index), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    private void DrawSpecialAntiMagic (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      //Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 0xA4 }), Color.Red, AlignementH.Center, AlignementV.Center, Color.White);
      DrawSpecialAntiMagic_ (g, x, y, size);
    }

    public static void DrawSpecialAntiMagic_ (Graphics g, int x, int y, int size) {
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, "AM", Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    private void DrawSpecialTeleport (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      Point src = _dungeonLevel._specialsTeleportYX [specialsIndex [0]];
      Point dst = _dungeonLevel._specialsTeleportDestYX [specialsIndex [0]];
      DrawSpecialTeleport_ (g, x, y, size, src, dst);
    }

    public static void DrawSpecialTeleport_ (Graphics g, int x, int y, int size, Point src, Point dst) {
      g.DrawArrowOutlined (_teleportColor, _teleportOutlineColor, x + size / 2, y + size / 2,
        x + (dst.X - src.X) * size + size / 2, y + (DungeonLevel.Height - dst.Y - 1 - (DungeonLevel.Height - src.Y - 1)) * size + size / 2, true, true);
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 0xA9 }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    private void DrawSpecialSpinner (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      DrawSpecialSpinner_ (g, x, y, size);
    }

    public static void DrawSpecialSpinner_ (Graphics g, int x, int y, int size) {
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2 + 1, new string (new char [] { (char) 0xBF, (char) 0x3F }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    private void DrawSpecialSmoke (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      DrawSpecialSmoke_ (g, x, y, size);
    }

    public static void DrawSpecialSmoke_ (Graphics g, int x, int y, int size) {
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2 + 1, new string (new char [] { (char) 0xAB, (char) 0xBB }), Color.Black, AlignementH.Center, AlignementV.Bottom, Color.White);
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2 - 1, new string (new char [] { (char) 0xAB, (char) 0xBB }), Color.Black, AlignementH.Center, AlignementV.Top, Color.White);
    }

    private void DrawSpecialDrainHealthPoint (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      DrawSpecialDrainHealthPoint_ (g, x, y, size);
    }

    public static void DrawSpecialDrainHealthPoint_ (Graphics g, int x, int y, int size) {
      g.FillRectangle (_drainColor, x + _doorThickness + 4, y + _doorThickness + 4, size - (_doorThickness + 4) * 2, size - (_doorThickness + 4) * 2);
    }

    private void DrawSpecialRegenerateSpellPoint (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      DrawSpecialRegenerateSpellPoint_ (g, x, y, size);
    }

    public static void DrawSpecialRegenerateSpellPoint_ (Graphics g, int x, int y, int size) {
      g.FillRectangle (_regenerateColor, x + _doorThickness + 4, y + _doorThickness + 4, size - (_doorThickness + 4) * 2, size - (_doorThickness + 4) * 2);
    }

    private void DrawSpecialImmobilize (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      DrawSpecialImmobilize_ (g, x, y, size);
    }

    public static void DrawSpecialImmobilize_ (Graphics g, int x, int y, int size) {
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 0xA4 }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    private void DrawSpecialText (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count != 1)
        throw new Exception ();
      int textIndex = _dungeonLevel._specialsTextIndex [specialsIndex [0]];
      DrawSpecialText_ (g, x, y, size, textIndex.ToString ());
    }

    public static void DrawSpecialText_ (Graphics g, int x, int y, int size, string index) {
      Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size - _wallThickness, string.Format ("T{0}", index), Color.Black, AlignementH.Center, AlignementV.Bottom, Color.White);
    }

    private void DrawSpecialFight (List<int> specialsIndex, Graphics g, int x, int y, int size) {
      if (specialsIndex.Count == 1)
        DrawSpecialFight_ (g, x, y, size, specialsIndex [0].ToString (), null);
      else if (specialsIndex.Count == 2)
        DrawSpecialFight_ (g, x, y, size, specialsIndex [0].ToString (), specialsIndex [1].ToString ());
      else
        throw new Exception ();
    }

    public static void DrawSpecialFight_ (Graphics g, int x, int y, int size, string index1, string index2) {
      if (index2 == null)
        Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, string.Format ("M{0}", index1), Color.Red, AlignementH.Center, AlignementV.Center, Color.White);
      else {
        Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, string.Format ("M{0}", index1), Color.Red, AlignementH.Left, AlignementV.Center, Color.White);
        Game._bitmapFontSmall.DrawText (g, x + size / 2, y + size / 2, string.Format ("M{0}", index2), Color.Red, AlignementH.Right, AlignementV.Center, Color.White);
      }
    }

    public static void DrawRandomMonster (Graphics g, int x, int y, int size) {
      g.FillEllipse (_monsterColor, x + _doorThickness + 6, y + _doorThickness + 6, size - (_doorThickness + 6) * 2 - 1, size - (_doorThickness + 6) * 2 - 1);
    }

    public static void DrawTrap (Graphics g, int x, int y, int size) {
      g.DrawRectangle (_trapColor, x + _doorThickness + 2, y + _doorThickness + 2, size - (_doorThickness + 2) * 2 - 1, size - (_doorThickness + 2) * 2 - 1);
      g.DrawRectangle (_trapColor, x + _doorThickness + 3, y + _doorThickness + 3, size - (_doorThickness + 3) * 2 - 1, size - (_doorThickness + 3) * 2 - 1);
    }

    public static void DrawDarkness (Graphics g, int x, int y, int size) {
      g.FillRectangle (_darknessColor, x, y, size, size);
    }
    public static void DrawStairsDown (Graphics g, int x, int y, int size) {
      Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 2 }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    public static void DrawStairsUp (Graphics g, int x, int y, int size) {
      Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 1 }), Color.Black, AlignementH.Center, AlignementV.Center, Color.White);
    }

    public static void DrawHoleDown (Graphics g, int x, int y, int size) {
      Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 2 }), Color.Red, AlignementH.Center, AlignementV.Center, Color.White);
    }

    public static void DrawHoleUp (Graphics g, int x, int y, int size) {
      Game._bitmapFont.DrawText (g, x + size / 2, y + size / 2, new string (new char [] { (char) 1 }), Color.Red, AlignementH.Center, AlignementV.Center, Color.White);
    }
  }
}
